package org.game.db.vo;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import com.google.common.collect.Maps;
import org.constant.RoleConstant;

import com.sojoys.artifact.build.data.base.ISerializable;
import com.sojoys.artifact.factory.bytebuff.IByteBuff;
import com.sojoys.artifact.manager.ByteBuffManager;
import com.sojoys.artifact.tools.ToolMap;

public class PlayerDataVO {
	/** 玩家离散 */
	public static class DiscreteVO implements ISerializable<DiscreteVO> {
		
		Date nowDate = new Date();
		
		/** 最后领取好友奖励时间 */
		private Date lastGetFriendGiftDate = nowDate;
		/** 领取好友奖励次数 */
		private int nowGetFriendGiftCount = 0;
		/** 天使免费重置次数 */
		private int resetAngelCount = 0;
		/** 助战英雄Cid */
		private int helpFigntHeroCid = 0;
		/** 助战英雄战斗力 */
		private int helpFigntHeroPower = 0;
		/** 新手引导 */
		private String newPlayerGuide = "";
		/** 活跃最后重置时间 */
		private Date lastResetActiveDate = nowDate;
		/** 活动精灵状态 */
		private int obtainRoleStatus = RoleConstant.STATUS_USE;
		/** 抽卡积分 */
		private int summonRankScore = 0;
		/** 上次quartz 城市约会点火时间 */
		private Date lastCityDatingFireTime = nowDate;
		/** 上次重置看板娘城市约会次数时间 */
		private Date lastResetCityDatingCountTime = nowDate;
		/** 玩家个性化设置 */
		private String settings = "";
		/** 最后清空天使免费重置次数时间 */
		private Date lastClearResetAngelDate = nowDate;
		/** 助战玩家冷却时间 */
		private Map<Integer, Long> helpFighterColdTimeMap = Maps.newHashMap();
		@Override
		public byte[] toBytes() {
			Map<Integer, Object> map = new HashMap<>();
			map.put(1, lastGetFriendGiftDate);
			map.put(2, nowGetFriendGiftCount);
			map.put(3, resetAngelCount);
			map.put(4, helpFigntHeroCid);
			map.put(5, helpFigntHeroPower);
			map.put(6, newPlayerGuide);
			map.put(7, lastResetActiveDate);
			map.put(8, obtainRoleStatus);
			map.put(9, summonRankScore);
			map.put(10, lastCityDatingFireTime);
			map.put(11, lastResetCityDatingCountTime);
			map.put(12, settings);
			map.put(13, lastClearResetAngelDate);
			map.put(14, helpFighterColdTimeMap);
			IByteBuff byteBuff = ByteBuffManager.me().allocate();
			byteBuff.writeMap(map);
			return byteBuff.toByte();
		}

		@Override
		public DiscreteVO createForBytes(byte[] data) {
			IByteBuff byteBuff = ByteBuffManager.me().wrap(data);
			Map<Integer, Object> map = byteBuff.readMap(null);
			lastGetFriendGiftDate = ToolMap.getDate(1, map);
			nowGetFriendGiftCount = ToolMap.getInt(2, map);
			resetAngelCount = ToolMap.getInt(3, map);
			helpFigntHeroCid = ToolMap.getInt(4, map);
			helpFigntHeroPower = ToolMap.getInt(5, map);
			newPlayerGuide = ToolMap.getString(6, map);
			lastResetActiveDate = ToolMap.getDate(7, map);
			obtainRoleStatus = ToolMap.getInt(8, map , RoleConstant.STATUS_USE);
			summonRankScore = ToolMap.getInt(9, map);
			lastCityDatingFireTime = ToolMap.getDate(10, map , nowDate);
			lastResetCityDatingCountTime = ToolMap.getDate(11, map , nowDate);
			settings = ToolMap.getString(12, map ,"");
			lastClearResetAngelDate = ToolMap.getDate(13, map , nowDate);
			helpFighterColdTimeMap = ToolMap.getMap(14,map, Maps.newHashMap());
			return this;
		}
		
		public Date getLastClearResetAngelDate() {
			return lastClearResetAngelDate;
		}

		public void setLastClearResetAngelDate(Date lastClearResetAngelDate) {
			this.lastClearResetAngelDate = lastClearResetAngelDate;
		}

		public String getSettings() {
			return settings;
		}

		public void setSettings(String settings) {
			this.settings = settings;
		}

		public Date getLastGetFriendGiftDate() {
			return lastGetFriendGiftDate;
		}

		public void setLastGetFriendGiftDate(Date lastGetFriendGiftDate) {
			this.lastGetFriendGiftDate = lastGetFriendGiftDate;
		}

		public int getNowGetFriendGiftCount() {
			return nowGetFriendGiftCount;
		}

		public void setNowGetFriendGiftCount(int nowGetFriendGiftCount) {
			this.nowGetFriendGiftCount = nowGetFriendGiftCount;
		}

		public int getResetAngelCount() {
			return resetAngelCount;
		}

		public void setResetAngelCount(int resetAngelCount) {
			this.resetAngelCount = resetAngelCount;
		}

		public int getHelpFigntHeroCid() {
			return helpFigntHeroCid;
		}

		public void setHelpFigntHeroCid(int helpFigntHeroCid) {
			this.helpFigntHeroCid = helpFigntHeroCid;
		}

		public int getHelpFigntHeroPower() {
			return helpFigntHeroPower;
		}

		public void setHelpFigntHeroPower(int helpFigntHeroPower) {
			this.helpFigntHeroPower = helpFigntHeroPower;
		}

		public String getNewPlayerGuide() {
			return newPlayerGuide;
		}

		public void setNewPlayerGuide(String newPlayerGuide) {
			this.newPlayerGuide = newPlayerGuide;
		}

		public Date getLastResetActiveDate() {
			return lastResetActiveDate;
		}

		public void setLastResetActiveDate(Date lastResetActiveDate) {
			this.lastResetActiveDate = lastResetActiveDate;
		}

		public int getObtainRoleStatus() {
			return obtainRoleStatus;
		}

		public void setObtainRoleStatus(int obtainRoleStatus) {
			this.obtainRoleStatus = obtainRoleStatus;
		}

		public int getSummonRankScore() {
			return summonRankScore;
		}

		public void setSummonRankScore(int summonRankScore) {
			this.summonRankScore = summonRankScore;
		}

		public Date getLastCityDatingFireTime() {
			return lastCityDatingFireTime;
		}

		public void setLastCityDatingFireTime(Date lastCityDatingFireTime) {
			this.lastCityDatingFireTime = lastCityDatingFireTime;
		}
		public Date getLastResetCityDatingCountTime() {
			return lastResetCityDatingCountTime;
		}
		public DiscreteVO setLastResetCityDatingCountTime(Date lastResetCityDatingCountTime) {
			this.lastResetCityDatingCountTime = lastResetCityDatingCountTime;
			return this;
		}

		public Map<Integer, Long> getHelpFighterColdTimeMap() {
			return helpFighterColdTimeMap;
		}

		public DiscreteVO setHelpFighterColdTimeMap(Map<Integer, Long> helpFighterColdTimeMap) {
			this.helpFighterColdTimeMap = helpFighterColdTimeMap;
			return this;
		}

		public long getHelpFightColdDownTime(int pid){
			return ToolMap.getLong(pid,helpFighterColdTimeMap,0);
		}
	}
	
	/** 抓娃娃 */
	public static class GashaponVO implements ISerializable<GashaponVO>{
		private int poolId = 0;
		private String pool = "";
		private long endTime = 0;
		private long refreshCD = 0;
		
		
		@Override
		public byte[] toBytes() {
			Map<Integer, Object> map = new HashMap<>();
			map.put(1, poolId);
			map.put(2, pool);
			map.put(3, endTime);
			map.put(4, refreshCD);

			IByteBuff byteBuff = ByteBuffManager.me().allocate();
			byteBuff.writeMap(map);
			return byteBuff.toByte();
		}

		@Override
		public GashaponVO createForBytes(byte[] data) {
			IByteBuff byteBuff = ByteBuffManager.me().wrap(data);
			Map<Integer, Object> map = byteBuff.readMap(null);
			poolId = ToolMap.getInt(1, map);
			pool = ToolMap.getString(2, map,"");
			endTime = ToolMap.getLong(3, map);
			refreshCD = ToolMap.getLong(4, map);
			return this;
		}

		public int getPoolId() {
			return poolId;
		}

		public void setPoolId(int poolId) {
			this.poolId = poolId;
		}

		public String getPool() {
			return pool;
		}

		public void setPool(String pool) {
			this.pool = pool;
		}

		public long getEndTime() {
			return endTime;
		}

		public void setEndTime(long endTime) {
			this.endTime = endTime;
		}

		public long getRefreshCD() {
			return refreshCD;
		}

		public void setRefreshCD(long refreshCD) {
			this.refreshCD = refreshCD;
		}
		
	}
	
	public static class EndlessVO implements ISerializable<EndlessVO>{
		private int nowStage = 0;
		/** 最近通关时间 */
		private long lastPassTime = 0;
		/** 最近领奖时间 */
		private long lastRewardTime = 0;
		/** 今日挑战时间 */
		private int todayBest = 0;
		/** 挑战总时间 */
		private int todayCostTime = 0;
		/** 离散最好成绩 */
		private int historyBest = 0;
		
		@Override
		public byte[] toBytes() {
			Map<Integer, Object> map = new HashMap<>();
			map.put(1, nowStage);
			map.put(2, lastPassTime);
			map.put(3, lastRewardTime);
			map.put(4, todayBest);
			map.put(5, todayCostTime);
			map.put(6, historyBest);

			IByteBuff byteBuff = ByteBuffManager.me().allocate();
			byteBuff.writeMap(map);
			return byteBuff.toByte();
		}

		@Override
		public EndlessVO createForBytes(byte[] data) {
			IByteBuff byteBuff = ByteBuffManager.me().wrap(data);
			Map<Integer, Object> map = byteBuff.readMap(null);
			nowStage = ToolMap.getInt(1, map);
			lastPassTime = ToolMap.getLong(2, map);
			lastRewardTime = ToolMap.getLong(3, map);
			todayBest = ToolMap.getInt(4, map);
			todayCostTime = ToolMap.getInt(5, map);
			historyBest = ToolMap.getInt(6, map);
			return this;
		}

		public long getLastPassTime() {
			return lastPassTime;
		}

		public void setLastPassTime(long lastPassTime) {
			this.lastPassTime = lastPassTime;
		}

		public long getLastRewardTime() {
			return lastRewardTime;
		}

		public void setLastRewardTime(long lastRewardTime) {
			this.lastRewardTime = lastRewardTime;
		}

		public int getTodayBest() {
			return todayBest;
		}

		public void setTodayBest(int todayBest) {
			this.todayBest = todayBest;
		}

		public int getTodayCostTime() {
			return todayCostTime;
		}

		public void setTodayCostTime(int todayCostTime) {
			this.todayCostTime = todayCostTime;
		}

		public int getHistoryBest() {
			return historyBest;
		}

		public void setHistoryBest(int historyBest) {
			this.historyBest = historyBest;
		}

		public int getNowStage() {
			return nowStage;
		}

		public void setNowStage(int nowStage) {
			this.nowStage = nowStage;
		}
	}
	
	/** 资源购买记录 */
	public static class ResBuyRecordVO implements ISerializable<ResBuyRecordVO>{
		/** 购买时间 */
		private long time = System.currentTimeMillis();
		/** 购买数量 */
		private int count = 0;
		@Override
		public byte[] toBytes() {
			Map<Integer, Object> map = new HashMap<>();
			map.put(1, time);
			map.put(2, count);

			IByteBuff byteBuff = ByteBuffManager.me().allocate();
			byteBuff.writeMap(map);
			return byteBuff.toByte();
		}
		@Override
		public ResBuyRecordVO createForBytes(byte[] data) {
			IByteBuff byteBuff = ByteBuffManager.me().wrap(data);
			Map<Integer, Object> map = byteBuff.readMap(null);
			time = ToolMap.getLong(1, map , System.currentTimeMillis());
			count = ToolMap.getInt(2, map , 0);
			return this;
		}
		public long getTime() {
			return time;
		}
		public void setTime(long time) {
			this.time = time;
		}
		public int getCount() {
			return count;
		}
		public void setCount(int count) {
			this.count = count;
		}
		
	}
}